<%@ page import="entity.User" %>
<%@ page import="entity.Page" %>
<%@ page import="entity.Book" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>图书管理系统</title>
    <link href="css/book.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<div class="wrap">
    <div class="head">
        <div class="head_left">
            <h2>图书管理系统</h2>
        </div>
        <div class="head_right">
            <div class="show">
                <div class="wel">
                    <h3>欢迎您</h3>
                </div>
                <div class="login">
                    <input type="text" readonly="readonly" value="<%=session.getAttribute("user")==null?"请先登录":((User)session.getAttribute("user")).getUserId()%>" />
                </div>
            </div>
            <div class="exit">
            </div>
        </div>
    </div>

    <div class="nav">
        <div class="list">
        </div>
    </div>

    <div class="body">
        <div class="list_left">
            <ul>
                <li>
                    <a class ="a1"  href="<%=session.getAttribute("user")==null?"login.jsp":"QueryBookByPageServlet"%>">图书管理</a>
                </li>
                <li>
                    <a class="a2"  href="<%=session.getAttribute("user")==null?"login.jsp":"QueryUsersByPageServlet"%>">用户管理</a>
                </li>
                <li>
                    <a class="a3"  href="<%=session.getAttribute("user")==null?"login.jsp":"RecordsCountByPageServlet"%>">借阅统计</a>
                </li>
                <li>
                    <a class="a4"  href="<%=session.getAttribute("user")==null?"login.jsp":"RecordsInformationByPageServlet"%>">图书借阅信息</a>
                </li>
                <li>
                    <a class="a5"  href="QuitServlet">安全退出</a>
                </li>
            </ul>
        </div>
        <div class="body_right">
            <div id="search">
                <div id="search_head">
                    <form id ="form1" method="post" action="QueryBookByPageServlet">
                        <input id="search_in" type="text" name="search_" required="required" placeholder="请输入账户或书名">
                        <input id="search_id" type="submit" value="查询书籍">
                    </form>
                    <form id ="form2" action="addBook.jsp" method="post">
                        <input id="add" type="submit" value="添加书籍">
                    </form>
                </div>
                <div id="search_body">
                    <table border="1px">
                        <tr>
                            <td>账号</td>
                            <td>书名</td>
                            <td>价格</td>
                            <td>作者</td>
                            <td>操作</td>
                            <td>操作</td>
                        </tr>
                        <%
                            Page page1=(Page)request.getAttribute("page");
                            if(page1.getBook()!=null){
                                for(Book book:page1.getBook()){
                        %>
                        <tr>
                            <td><a href="QueryBookInformationServlet?bookId=<%=book.getBookId()%>"><%=book.getBookId()%></a></td>
                            <td><%=book.getBookName()%></td>
                            <td><%=book.getPrice()%></td>
                            <td><%=book.getAuthor()%></td>
                            <td><a href="DeleteBookServlet?bookId=<%=book.getBookId()%>">删除</a></td>
                            <td><a href="QueryBookInformationServlet?bookId=<%=book.getBookId()%>">修改</a> </td>
                        </tr>

                        <%
                                }
                            }
                        %>
                    </table>
                </div>
                <div id="search_bo">
                    <%
                        if(page1.getCurrentPage()==page1.getTotalPage()-1&&page1.getCurrentPage()==0||page1.getTotalCount()==0){
                    %>
                    <a href="QueryBookByPageServlet?currentPage=0%>">没有更多数据</a>
                    <%
                    }else if(page1.getCurrentPage()==0){
                    %>
                    <a class ="nextPage" href="QueryBookByPageServlet?currentPage=<%=page1.getCurrentPage()+1%>&search_=<%=session.getAttribute("search_")%>">下一页</a>
                    <a class="deadPage" href="QueryBookByPageServlet?currentPage=<%=page1.getTotalPage()-1%>&search_=<%=session.getAttribute("search_")%>">尾页</a>
                    <%
                    }else if(page1.getCurrentPage()==page1.getTotalPage()-1){
                    %>
                    <a class ="startPage" href="QueryBookByPageServlet?currentPage=0&search_=<%=session.getAttribute("search_")%>">首页</a>
                    <a class="beforePage" href="QueryBookByPageServlet?currentPage=<%=page1.getCurrentPage()-1%>&search_=<%=session.getAttribute("search_")%>">上一页</a>
                    <%
                    }else{
                    %>
                    <a class ="startPage" href="QueryBookByPageServlet?currentPage=0&search_=<%=session.getAttribute("search_")%>">首页</a>
                    <a class="beforePage" href="QueryBookByPageServlet?currentPage=<%=page1.getCurrentPage()-1%>&search_=<%=session.getAttribute("search_")%>">上一页</a>
                    <a class ="nextPage" href="QueryBookByPageServlet?currentPage=<%=page1.getCurrentPage()+1%>&search_=<%=session.getAttribute("search_")%>">下一页</a>
                    <a class="deadPage" href="QueryBookByPageServlet?currentPage=<%=page1.getTotalPage()-1%>&search_=<%=session.getAttribute("search_")%>">尾页</a>
                    <%
                        }
                    %>
                    <a id="upload" href="UploadServlet?fileName=书籍名单.txt">导出书籍名单</a>
                </div>
            </div>
        </div>
    </div>

    <div class="flooter">
        <div class="foot">
            Copyright &copy; 2022-2032 SSPU-lyx.com 版权所有
        </div>
    </div>
</div>
</body>
</html>